home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / jce.jar / javax / crypto / Cipher.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-07-27  |  16.0 KB  |  904 lines

  1. package javax.crypto;
  2.  
  3. import java.nio.ByteBuffer;
  4. import java.nio.ReadOnlyBufferException;
  5. import java.security.AlgorithmParameters;
  6. import java.security.InvalidAlgorithmParameterException;
  7. import java.security.InvalidKeyException;
  8. import java.security.InvalidParameterException;
  9. import java.security.Key;
  10. import java.security.NoSuchAlgorithmException;
  11. import java.security.NoSuchProviderException;
  12. import java.security.Provider;
  13. import java.security.ProviderException;
  14. import java.security.PublicKey;
  15. import java.security.SecureRandom;
  16. import java.security.Security;
  17. import java.security.cert.Certificate;
  18. import java.security.cert.X509Certificate;
  19. import java.security.spec.AlgorithmParameterSpec;
  20. import java.security.spec.InvalidParameterSpecException;
  21. import java.util.ArrayList;
  22. import java.util.Collections;
  23. import java.util.Iterator;
  24. import java.util.List;
  25. import java.util.Locale;
  26. import java.util.NoSuchElementException;
  27. import java.util.Set;
  28. import java.util.StringTokenizer;
  29. import javax.crypto.spec.IvParameterSpec;
  30. import javax.crypto.spec.PBEParameterSpec;
  31. import javax.crypto.spec.RC2ParameterSpec;
  32. import javax.crypto.spec.RC5ParameterSpec;
  33. import sun.security.jca.GetInstance;
  34. import sun.security.jca.ServiceId;
  35. import sun.security.util.Debug;
  36.  
  37. public class Cipher {
  38.    // $FF: renamed from: a sun.security.util.Debug
  39.    private static final Debug field_0 = Debug.getInstance("jca", "Cipher");
  40.    public static final int ENCRYPT_MODE = 1;
  41.    public static final int DECRYPT_MODE = 2;
  42.    public static final int WRAP_MODE = 3;
  43.    public static final int UNWRAP_MODE = 4;
  44.    public static final int PUBLIC_KEY = 1;
  45.    public static final int PRIVATE_KEY = 2;
  46.    public static final int SECRET_KEY = 3;
  47.    // $FF: renamed from: b java.security.Provider
  48.    private Provider field_1;
  49.    // $FF: renamed from: c javax.crypto.CipherSpi
  50.    private CipherSpi field_2;
  51.    // $FF: renamed from: d java.lang.String
  52.    private String field_3;
  53.    // $FF: renamed from: e javax.crypto.SunJCE_f
  54.    private SunJCE_f field_4;
  55.    // $FF: renamed from: f javax.crypto.ExemptionMechanism
  56.    private ExemptionMechanism field_5;
  57.    // $FF: renamed from: g boolean
  58.    private boolean field_6 = false;
  59.    // $FF: renamed from: h int
  60.    private int field_7 = 0;
  61.    // $FF: renamed from: i java.lang.String
  62.    private static final String field_8 = "2.5.29.15";
  63.    // $FF: renamed from: j javax.crypto.CipherSpi
  64.    private CipherSpi field_9;
  65.    // $FF: renamed from: k java.security.Provider.Service
  66.    private Provider.Service field_10;
  67.    // $FF: renamed from: l java.util.Iterator
  68.    private Iterator field_11;
  69.    // $FF: renamed from: m java.util.List
  70.    private List field_12;
  71.    // $FF: renamed from: n java.lang.Object
  72.    private final Object field_13;
  73.    // $FF: renamed from: o java.lang.String
  74.    private static final String field_14 = "SupportedModes";
  75.    // $FF: renamed from: p java.lang.String
  76.    private static final String field_15 = "SupportedPaddings";
  77.    // $FF: renamed from: q int
  78.    private static final int field_16 = 0;
  79.    // $FF: renamed from: r int
  80.    private static final int field_17 = 1;
  81.    // $FF: renamed from: s int
  82.    private static final int field_18 = 2;
  83.    // $FF: renamed from: t int
  84.    private static int field_19 = 10;
  85.    // $FF: renamed from: u int
  86.    private static final int field_20 = 1;
  87.    // $FF: renamed from: v int
  88.    private static final int field_21 = 2;
  89.    // $FF: renamed from: w int
  90.    private static final int field_22 = 3;
  91.    // $FF: renamed from: x int
  92.    private static final int field_23 = 4;
  93.  
  94.    protected Cipher(CipherSpi var1, Provider var2, String var3) {
  95.       if (!SunJCE_h.f.a()) {
  96.          throw new NullPointerException();
  97.       } else {
  98.          this.field_2 = var1;
  99.          this.field_1 = var2;
  100.          this.field_3 = var3;
  101.          this.field_4 = SunJCE_k.b;
  102.          this.field_13 = null;
  103.       }
  104.    }
  105.  
  106.    Cipher(CipherSpi var1, String var2) {
  107.       this.field_2 = var1;
  108.       this.field_3 = var2;
  109.       this.field_4 = SunJCE_k.b;
  110.       this.field_13 = null;
  111.    }
  112.  
  113.    private Cipher(CipherSpi var1, Provider.Service var2, Iterator var3, String var4, List var5) {
  114.       this.field_9 = var1;
  115.       this.field_10 = var2;
  116.       this.field_11 = var3;
  117.       this.field_12 = var5;
  118.       this.field_3 = var4;
  119.       this.field_13 = new Object();
  120.    }
  121.  
  122.    // $FF: renamed from: a (java.lang.String) java.lang.String[]
  123.    private static String[] method_0(String var0) throws NoSuchAlgorithmException {
  124.       if (var0 == null) {
  125.          throw new NoSuchAlgorithmException("No transformation given");
  126.       } else {
  127.          String[] var1 = new String[3];
  128.          int var2 = 0;
  129.          StringTokenizer var3 = new StringTokenizer(var0, "/");
  130.  
  131.          try {
  132.             while(var3.hasMoreTokens() && var2 < 3) {
  133.                var1[var2++] = var3.nextToken().trim();
  134.             }
  135.  
  136.             if (var2 == 0 || var2 == 2 || var3.hasMoreTokens()) {
  137.                throw new NoSuchAlgorithmException("Invalid transformation format:" + var0);
  138.             }
  139.          } catch (NoSuchElementException var5) {
  140.             throw new NoSuchAlgorithmException("Invalid transformation format:" + var0);
  141.          }
  142.  
  143.          if (var1[0] != null && var1[0].length() != 0) {
  144.             return var1;
  145.          } else {
  146.             throw new NoSuchAlgorithmException("Invalid transformation:algorithm not specified-" + var0);
  147.          }
  148.       }
  149.    }
  150.  
  151.    // $FF: renamed from: b (java.lang.String) java.util.List
  152.    private static List method_1(String var0) throws NoSuchAlgorithmException {
  153.       String[] var1 = method_0(var0);
  154.       String var2 = var1[0];
  155.       String var3 = var1[1];
  156.       String var4 = var1[2];
  157.       if (var3 != null && var3.length() == 0) {
  158.          var3 = null;
  159.       }
  160.  
  161.       if (var4 != null && var4.length() == 0) {
  162.          var4 = null;
  163.       }
  164.  
  165.       if (var3 == null && var4 == null) {
  166.          r var6 = new r(var2, "", (String)null, (String)null);
  167.          return Collections.singletonList(var6);
  168.       } else {
  169.          ArrayList var5 = new ArrayList(4);
  170.          var5.add(new r(var2, "/" + var3 + "/" + var4, (String)null, (String)null));
  171.          var5.add(new r(var2, "/" + var3, (String)null, var4));
  172.          var5.add(new r(var2, "//" + var4, var3, (String)null));
  173.          var5.add(new r(var2, "", var3, var4));
  174.          return var5;
  175.       }
  176.    }
  177.  
  178.    // $FF: renamed from: a (java.security.Provider.Service, java.util.List) javax.crypto.Cipher.r
  179.    private static r method_2(Provider.Service var0, List var1) {
  180.       String var2 = var0.getAlgorithm().toUpperCase(Locale.ENGLISH);
  181.  
  182.       for(r var4 : var1) {
  183.          if (var2.endsWith(var4.b)) {
  184.             return var4;
  185.          }
  186.       }
  187.  
  188.       return null;
  189.    }
  190.  
  191.    public static final Cipher getInstance(String var0) throws NoSuchAlgorithmException, NoSuchPaddingException {
  192.       List var1 = method_1(var0);
  193.       ArrayList var2 = new ArrayList(var1.size());
  194.  
  195.       for(r var4 : var1) {
  196.          var2.add(new ServiceId("Cipher", var4.a));
  197.       }
  198.  
  199.       List var11 = GetInstance.getServices(var2);
  200.       Iterator var12 = var11.iterator();
  201.       Exception var5 = null;
  202.  
  203.       while(var12.hasNext()) {
  204.          Provider.Service var6 = (Provider.Service)var12.next();
  205.          if (SunJCE_b.b(var6.getProvider())) {
  206.             r var7 = method_2(var6, var1);
  207.             if (var7 != null) {
  208.                int var8 = var7.a(var6);
  209.                if (var8 != 0) {
  210.                   if (var8 == 2) {
  211.                      return new Cipher((CipherSpi)null, var6, var12, var0, var1);
  212.                   }
  213.  
  214.                   try {
  215.                      CipherSpi var9 = (CipherSpi)var6.newInstance((Object)null);
  216.                      var7.a(var9);
  217.                      return new Cipher(var9, var6, var12, var0, var1);
  218.                   } catch (Exception var10) {
  219.                      var5 = var10;
  220.                   }
  221.                }
  222.             }
  223.          }
  224.       }
  225.  
  226.       throw new NoSuchAlgorithmException("Cannot find any provider supporting " + var0, var5);
  227.    }
  228.  
  229.    public static final Cipher getInstance(String var0, String var1) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException {
  230.       if (var1 != null && var1.length() != 0) {
  231.          Provider var2 = Security.getProvider(var1);
  232.          if (var2 == null) {
  233.             throw new NoSuchProviderException("No such provider: " + var1);
  234.          } else {
  235.             return getInstance(var0, var2);
  236.          }
  237.       } else {
  238.          throw new IllegalArgumentException("Missing provider");
  239.       }
  240.    }
  241.  
  242.    public static final Cipher getInstance(String var0, Provider var1) throws NoSuchAlgorithmException, NoSuchPaddingException {
  243.       if (var1 == null) {
  244.          throw new IllegalArgumentException("Missing provider");
  245.       } else {
  246.          Exception var2 = null;
  247.          List var3 = method_1(var0);
  248.          boolean var4 = false;
  249.          String var5 = null;
  250.  
  251.          for(r var7 : var3) {
  252.             Provider.Service var8 = var1.getService("Cipher", var7.a);
  253.             if (var8 != null) {
  254.                if (!var4) {
  255.                   Exception var9 = SunJCE_b.a(var1);
  256.                   if (var9 != null) {
  257.                      String var13 = "JCE cannot authenticate the provider " + var1.getName();
  258.                      throw new SecurityException(var13, var9);
  259.                   }
  260.  
  261.                   var4 = true;
  262.                }
  263.  
  264.                if (var7.b(var8) != 0) {
  265.                   if (var7.c(var8) != 0) {
  266.                      try {
  267.                         CipherSpi var12 = (CipherSpi)var8.newInstance((Object)null);
  268.                         var7.a(var12);
  269.                         Cipher var10 = new Cipher(var12, var0);
  270.                         var10.field_1 = var8.getProvider();
  271.                         var10.method_3();
  272.                         return var10;
  273.                      } catch (Exception var11) {
  274.                         var2 = var11;
  275.                      }
  276.                   } else {
  277.                      var5 = var7.d;
  278.                   }
  279.                }
  280.             }
  281.          }
  282.  
  283.          if (var2 instanceof NoSuchPaddingException) {
  284.             throw (NoSuchPaddingException)var2;
  285.          } else if (var5 != null) {
  286.             throw new NoSuchPaddingException("Padding not supported: " + var5);
  287.          } else {
  288.             throw new NoSuchAlgorithmException("No such algorithm: " + var0, var2);
  289.          }
  290.       }
  291.    }
  292.  
  293.    // $FF: renamed from: b () void
  294.    private void method_3() throws NoSuchAlgorithmException {
  295.       if (!SunJCE_b.c()) {
  296.          this.field_4 = SunJCE_k.b;
  297.          this.field_5 = null;
  298.       } else {
  299.          this.field_4 = method_14(this.field_3);
  300.          String var1 = this.field_4.b();
  301.          if (var1 != null) {
  302.             this.field_5 = ExemptionMechanism.getInstance(var1);
  303.          }
  304.  
  305.       }
  306.    }
  307.  
  308.    // $FF: renamed from: a () void
  309.    void method_4() {
  310.       if (this.field_2 == null) {
  311.          synchronized(this.field_13) {
  312.             if (this.field_2 == null) {
  313.                if (field_0 != null) {
  314.                   int var2 = --field_19;
  315.                   if (var2 >= 0) {
  316.                      field_0.println("Cipher.init() not first method called, disabling delayed provider selection");
  317.                      if (var2 == 0) {
  318.                         field_0.println("Further warnings of this type will be suppressed");
  319.                      }
  320.  
  321.                      (new Exception("Call trace")).printStackTrace();
  322.                   }
  323.                }
  324.  
  325.                Exception var10 = null;
  326.  
  327.                while(this.field_10 != null || this.field_11.hasNext()) {
  328.                   Provider.Service var3;
  329.                   CipherSpi var4;
  330.                   if (this.field_10 != null) {
  331.                      var3 = this.field_10;
  332.                      var4 = this.field_9;
  333.                      this.field_10 = null;
  334.                      this.field_9 = null;
  335.                   } else {
  336.                      var3 = (Provider.Service)this.field_11.next();
  337.                      var4 = null;
  338.                   }
  339.  
  340.                   if (SunJCE_b.b(var3.getProvider())) {
  341.                      r var5 = method_2(var3, this.field_12);
  342.                      if (var5 != null && var5.a(var3) != 0) {
  343.                         try {
  344.                            if (var4 == null) {
  345.                               Object var6 = var3.newInstance((Object)null);
  346.                               if (!(var6 instanceof CipherSpi)) {
  347.                                  continue;
  348.                               }
  349.  
  350.                               var4 = (CipherSpi)var6;
  351.                            }
  352.  
  353.                            var5.a(var4);
  354.                            this.method_3();
  355.                            this.field_2 = var4;
  356.                            this.field_1 = var3.getProvider();
  357.                            this.field_10 = null;
  358.                            this.field_11 = null;
  359.                            this.field_12 = null;
  360.                            return;
  361.                         } catch (Exception var8) {
  362.                            var10 = var8;
  363.                         }
  364.                      }
  365.                   }
  366.                }
  367.  
  368.                ProviderException var11 = new ProviderException("Could not construct CipherSpi instance");
  369.                if (var10 != null) {
  370.                   var11.initCause(var10);
  371.                }
  372.  
  373.                throw var11;
  374.             }
  375.          }
  376.       }
  377.    }
  378.  
  379.    // $FF: renamed from: a (javax.crypto.CipherSpi, int, int, java.security.Key, java.security.spec.AlgorithmParameterSpec, java.security.AlgorithmParameters, java.security.SecureRandom) void
  380.    private void method_5(CipherSpi var1, int var2, int var3, Key var4, AlgorithmParameterSpec var5, AlgorithmParameters var6, SecureRandom var7) throws InvalidKeyException, InvalidAlgorithmParameterException {
  381.       switch (var2) {
  382.          case 1:
  383.             this.method_7(var1, var4);
  384.             var1.engineInit(var3, var4, var7);
  385.             break;
  386.          case 2:
  387.             this.method_8(var1, var4, var5);
  388.             var1.engineInit(var3, var4, var5, var7);
  389.             break;
  390.          case 3:
  391.             this.method_9(var1, var4, var6);
  392.             var1.engineInit(var3, var4, var6, var7);
  393.             break;
  394.          case 4:
  395.             this.method_7(var1, var4);
  396.             var1.engineInit(var3, var4, var7);
  397.             break;
  398.          default:
  399.             throw new AssertionError("Internal Cipher error: " + var2);
  400.       }
  401.  
  402.    }
  403.  
  404.    // $FF: renamed from: a (int, int, java.security.Key, java.security.spec.AlgorithmParameterSpec, java.security.AlgorithmParameters, java.security.SecureRandom) void
  405.    private void method_6(int var1, int var2, Key var3, AlgorithmParameterSpec var4, AlgorithmParameters var5, SecureRandom var6) throws InvalidKeyException, InvalidAlgorithmParameterException {
  406.       synchronized(this.field_13) {
  407.          if (this.field_2 != null) {
  408.             this.method_5(this.field_2, var1, var2, var3, var4, var5, var6);
  409.          } else {
  410.             Exception var8 = null;
  411.  
  412.             while(this.field_10 != null || this.field_11.hasNext()) {
  413.                Provider.Service var9;
  414.                CipherSpi var10;
  415.                if (this.field_10 != null) {
  416.                   var9 = this.field_10;
  417.                   var10 = this.field_9;
  418.                   this.field_10 = null;
  419.                   this.field_9 = null;
  420.                } else {
  421.                   var9 = (Provider.Service)this.field_11.next();
  422.                   var10 = null;
  423.                }
  424.  
  425.                if (var9.supportsParameter(var3) && SunJCE_b.b(var9.getProvider())) {
  426.                   r var11 = method_2(var9, this.field_12);
  427.                   if (var11 != null && var11.a(var9) != 0) {
  428.                      try {
  429.                         if (var10 == null) {
  430.                            var10 = (CipherSpi)var9.newInstance((Object)null);
  431.                         }
  432.  
  433.                         var11.a(var10);
  434.                         this.method_3();
  435.                         this.method_5(var10, var1, var2, var3, var4, var5, var6);
  436.                         this.field_1 = var9.getProvider();
  437.                         this.field_2 = var10;
  438.                         this.field_10 = null;
  439.                         this.field_11 = null;
  440.                         this.field_12 = null;
  441.                         return;
  442.                      } catch (Exception var14) {
  443.                         if (var8 == null) {
  444.                            var8 = var14;
  445.                         }
  446.                      }
  447.                   }
  448.                }
  449.             }
  450.  
  451.             if (var8 instanceof InvalidKeyException) {
  452.                throw (InvalidKeyException)var8;
  453.             } else if (var8 instanceof InvalidAlgorithmParameterException) {
  454.                throw (InvalidAlgorithmParameterException)var8;
  455.             } else if (var8 instanceof RuntimeException) {
  456.                throw (RuntimeException)var8;
  457.             } else {
  458.                String var16 = var3 != null ? var3.getClass().getName() : "(null)";
  459.                throw new InvalidKeyException("No installed provider supports this key: " + var16, var8);
  460.             }
  461.          }
  462.       }
  463.    }
  464.  
  465.    public final Provider getProvider() {
  466.       this.method_4();
  467.       return this.field_1;
  468.    }
  469.  
  470.    public final String getAlgorithm() {
  471.       return this.field_3;
  472.    }
  473.  
  474.    public final int getBlockSize() {
  475.       this.method_4();
  476.       return this.field_2.engineGetBlockSize();
  477.    }
  478.  
  479.    public final int getOutputSize(int var1) {
  480.       if (!this.field_6 && !(this instanceof NullCipher)) {
  481.          throw new IllegalStateException("Cipher not initialized");
  482.       } else if (var1 < 0) {
  483.          throw new IllegalArgumentException("Input size must be equal to or greater than zero");
  484.       } else {
  485.          this.method_4();
  486.          return this.field_2.engineGetOutputSize(var1);
  487.       }
  488.    }
  489.  
  490.    public final byte[] getIV() {
  491.       this.method_4();
  492.       return this.field_2.engineGetIV();
  493.    }
  494.  
  495.    public final AlgorithmParameters getParameters() {
  496.       this.method_4();
  497.       return this.field_2.engineGetParameters();
  498.    }
  499.  
  500.    public final ExemptionMechanism getExemptionMechanism() {
  501.       this.method_4();
  502.       return this.field_5;
  503.    }
  504.  
  505.    // $FF: renamed from: a (javax.crypto.CipherSpi, java.security.Key) void
  506.    private void method_7(CipherSpi var1, Key var2) throws InvalidKeyException {
  507.       if (this.field_4 != SunJCE_k.b) {
  508.          AlgorithmParameterSpec var3;
  509.          try {
  510.             var3 = this.method_13(var1.engineGetParameters());
  511.          } catch (InvalidParameterSpecException var5) {
  512.             throw new InvalidKeyException("Unsupported default algorithm parameters");
  513.          }
  514.  
  515.          if (!this.method_10(var1, var2, var3)) {
  516.             throw new InvalidKeyException("Illegal key size or default parameters");
  517.          }
  518.       }
  519.    }
  520.  
  521.    // $FF: renamed from: a (javax.crypto.CipherSpi, java.security.Key, java.security.spec.AlgorithmParameterSpec) void
  522.    private void method_8(CipherSpi var1, Key var2, AlgorithmParameterSpec var3) throws InvalidKeyException, InvalidAlgorithmParameterException {
  523.       if (this.field_4 != SunJCE_k.b) {
  524.          if (!this.method_10(var1, var2, (AlgorithmParameterSpec)null)) {
  525.             throw new InvalidKeyException("Illegal key size");
  526.          } else if (var3 != null && !this.method_10(var1, var2, var3)) {
  527.             throw new InvalidAlgorithmParameterException("Illegal parameters");
  528.          }
  529.       }
  530.    }
  531.  
  532.    // $FF: renamed from: a (javax.crypto.CipherSpi, java.security.Key, java.security.AlgorithmParameters) void
  533.    private void method_9(CipherSpi var1, Key var2, AlgorithmParameters var3) throws InvalidKeyException, InvalidAlgorithmParameterException {
  534.       if (this.field_4 != SunJCE_k.b) {
  535.          AlgorithmParameterSpec var4;
  536.          try {
  537.             var4 = this.method_13(var3);
  538.          } catch (InvalidParameterSpecException var6) {
  539.             throw new InvalidAlgorithmParameterException("Failed to retrieve algorithm parameter specification");
  540.          }
  541.  
  542.          this.method_8(var1, var2, var4);
  543.       }
  544.    }
  545.  
  546.    // $FF: renamed from: b (javax.crypto.CipherSpi, java.security.Key, java.security.spec.AlgorithmParameterSpec) boolean
  547.    private boolean method_10(CipherSpi var1, Key var2, AlgorithmParameterSpec var3) throws InvalidKeyException {
  548.       String var4 = this.field_4.b();
  549.       int var5 = var1.engineGetKeySize(var2);
  550.       int var7 = this.field_3.indexOf(47);
  551.       String var6;
  552.       if (var7 != -1) {
  553.          var6 = this.field_3.substring(0, var7);
  554.       } else {
  555.          var6 = this.field_3;
  556.       }
  557.  
  558.       SunJCE_f var8 = new SunJCE_f(var6, var5, var3, var4);
  559.       if (!this.field_4.implies(var8)) {
  560.          if (field_0 != null) {
  561.             field_0.println("Crypto Permission check failed");
  562.             field_0.println("granted: " + this.field_4);
  563.             field_0.println("requesting: " + var8);
  564.          }
  565.  
  566.          return false;
  567.       } else if (this.field_5 == null) {
  568.          return true;
  569.       } else {
  570.          try {
  571.             if (!this.field_5.isCryptoAllowed(var2)) {
  572.                if (field_0 != null) {
  573.                   field_0.println(this.field_5.getName() + " isn't enforced");
  574.                }
  575.  
  576.                return false;
  577.             } else {
  578.                return true;
  579.             }
  580.          } catch (ExemptionMechanismException var10) {
  581.             if (field_0 != null) {
  582.                field_0.println("Cannot determine whether " + this.field_5.getName() + " has been enforced");
  583.                ((Throwable)var10).printStackTrace();
  584.             }
  585.  
  586.             return false;
  587.          }
  588.       }
  589.    }
  590.  
  591.    // $FF: renamed from: a (int) void
  592.    private static void method_11(int var0) {
  593.       if (var0 < 1 || var0 > 4) {
  594.          throw new InvalidParameterException("Invalid operation mode");
  595.       }
  596.    }
  597.  
  598.    public final void init(int var1, Key var2) throws InvalidKeyException {
  599.       this.init(var1, var2, SunJCE_b.b);
  600.    }
  601.  
  602.    public final void init(int var1, Key var2, SecureRandom var3) throws InvalidKeyException {
  603.       this.field_6 = false;
  604.       method_11(var1);
  605.       if (this.field_2 != null) {
  606.          this.method_7(this.field_2, var2);
  607.          this.field_2.engineInit(var1, var2, var3);
  608.       } else {
  609.          try {
  610.             this.method_6(1, var1, var2, (AlgorithmParameterSpec)null, (AlgorithmParameters)null, var3);
  611.          } catch (InvalidAlgorithmParameterException var5) {
  612.             throw new InvalidKeyException(var5);
  613.          }
  614.       }
  615.  
  616.       this.field_6 = true;
  617.       this.field_7 = var1;
  618.    }
  619.  
  620.    public final void init(int var1, Key var2, AlgorithmParameterSpec var3) throws InvalidKeyException, InvalidAlgorithmParameterException {
  621.       this.init(var1, var2, var3, SunJCE_b.b);
  622.    }
  623.  
  624.    public final void init(int var1, Key var2, AlgorithmParameterSpec var3, SecureRandom var4) throws InvalidKeyException, InvalidAlgorithmParameterException {
  625.       this.field_6 = false;
  626.       method_11(var1);
  627.       if (this.field_2 != null) {
  628.          this.method_8(this.field_2, var2, var3);
  629.          this.field_2.engineInit(var1, var2, var3, var4);
  630.       } else {
  631.          this.method_6(2, var1, var2, var3, (AlgorithmParameters)null, var4);
  632.       }
  633.  
  634.       this.field_6 = true;
  635.       this.field_7 = var1;
  636.    }
  637.  
  638.    public final void init(int var1, Key var2, AlgorithmParameters var3) throws InvalidKeyException, InvalidAlgorithmParameterException {
  639.       this.init(var1, var2, var3, SunJCE_b.b);
  640.    }
  641.  
  642.    public final void init(int var1, Key var2, AlgorithmParameters var3, SecureRandom var4) throws InvalidKeyException, InvalidAlgorithmParameterException {
  643.       this.field_6 = false;
  644.       method_11(var1);
  645.       if (this.field_2 != null) {
  646.          this.method_9(this.field_2, var2, var3);
  647.          this.field_2.engineInit(var1, var2, var3, var4);
  648.       } else {
  649.          this.method_6(3, var1, var2, (AlgorithmParameterSpec)null, var3, var4);
  650.       }
  651.  
  652.       this.field_6 = true;
  653.       this.field_7 = var1;
  654.    }
  655.  
  656.    public final void init(int var1, Certificate var2) throws InvalidKeyException {
  657.       this.init(var1, var2, SunJCE_b.b);
  658.    }
  659.  
  660.    public final void init(int var1, Certificate var2, SecureRandom var3) throws InvalidKeyException {
  661.       this.field_6 = false;
  662.       method_11(var1);
  663.       if (var2 instanceof X509Certificate) {
  664.          X509Certificate var4 = (X509Certificate)var2;
  665.          Set var5 = var4.getCriticalExtensionOIDs();
  666.          if (var5 != null && !var5.isEmpty() && var5.contains("2.5.29.15")) {
  667.             boolean[] var6 = var4.getKeyUsage();
  668.             if (var6 != null && (var1 == 1 && var6.length > 3 && !var6[3] || var1 == 3 && var6.length > 2 && !var6[2])) {
  669.                throw new InvalidKeyException("Wrong key usage");
  670.             }
  671.          }
  672.       }
  673.  
  674.       PublicKey var8 = var2 == null ? null : var2.getPublicKey();
  675.       if (this.field_2 != null) {
  676.          this.method_7(this.field_2, var8);
  677.          this.field_2.engineInit(var1, var8, var3);
  678.       } else {
  679.          try {
  680.             this.method_6(4, var1, var8, (AlgorithmParameterSpec)null, (AlgorithmParameters)null, var3);
  681.          } catch (InvalidAlgorithmParameterException var7) {
  682.             throw new InvalidKeyException(var7);
  683.          }
  684.       }
  685.  
  686.       this.field_6 = true;
  687.       this.field_7 = var1;
  688.    }
  689.  
  690.    // $FF: renamed from: c () void
  691.    private void method_12() {
  692.       if (!(this instanceof NullCipher)) {
  693.          if (!this.field_6) {
  694.             throw new IllegalStateException("Cipher not initialized");
  695.          }
  696.  
  697.          if (this.field_7 != 1 && this.field_7 != 2) {
  698.             throw new IllegalStateException("Cipher not initialized for encryption/decryption");
  699.          }
  700.       }
  701.  
  702.    }
  703.  
  704.    public final byte[] update(byte[] var1) {
  705.       this.method_12();
  706.       if (var1 == null) {
  707.          throw new IllegalArgumentException("Null input buffer");
  708.       } else {
  709.          this.method_4();
  710.          return var1.length == 0 ? null : this.field_2.engineUpdate(var1, 0, var1.length);
  711.       }
  712.    }
  713.  
  714.    public final byte[] update(byte[] var1, int var2, int var3) {
  715.       this.method_12();
  716.       if (var1 != null && var2 >= 0 && var3 <= var1.length - var2 && var3 >= 0) {
  717.          this.method_4();
  718.          return var3 == 0 ? null : this.field_2.engineUpdate(var1, var2, var3);
  719.       } else {
  720.          throw new IllegalArgumentException("Bad arguments");
  721.       }
  722.    }
  723.  
  724.    public final int update(byte[] var1, int var2, int var3, byte[] var4) throws ShortBufferException {
  725.       this.method_12();
  726.       if (var1 != null && var2 >= 0 && var3 <= var1.length - var2 && var3 >= 0) {
  727.          this.method_4();
  728.          return var3 == 0 ? 0 : this.field_2.engineUpdate(var1, var2, var3, var4, 0);
  729.       } else {
  730.          throw new IllegalArgumentException("Bad arguments");
  731.       }
  732.    }
  733.  
  734.    public final int update(byte[] var1, int var2, int var3, byte[] var4, int var5) throws ShortBufferException {
  735.       this.method_12();
  736.       if (var1 != null && var2 >= 0 && var3 <= var1.length - var2 && var3 >= 0 && var5 >= 0) {
  737.          this.method_4();
  738.          return var3 == 0 ? 0 : this.field_2.engineUpdate(var1, var2, var3, var4, var5);
  739.       } else {
  740.          throw new IllegalArgumentException("Bad arguments");
  741.       }
  742.    }
  743.  
  744.    public final int update(ByteBuffer var1, ByteBuffer var2) throws ShortBufferException {
  745.       this.method_12();
  746.       if (var1 != null && var2 != null) {
  747.          if (var1 == var2) {
  748.             throw new IllegalArgumentException("Input and output buffers must not be the same object, consider using buffer.duplicate()");
  749.          } else if (var2.isReadOnly()) {
  750.             throw new ReadOnlyBufferException();
  751.          } else {
  752.             this.method_4();
  753.             return this.field_2.engineUpdate(var1, var2);
  754.          }
  755.       } else {
  756.          throw new IllegalArgumentException("Buffers must not be null");
  757.       }
  758.    }
  759.  
  760.    public final byte[] doFinal() throws IllegalBlockSizeException, BadPaddingException {
  761.       this.method_12();
  762.       this.method_4();
  763.       return this.field_2.engineDoFinal((byte[])null, 0, 0);
  764.    }
  765.  
  766.    public final int doFinal(byte[] var1, int var2) throws IllegalBlockSizeException, ShortBufferException, BadPaddingException {
  767.       this.method_12();
  768.       if (var1 != null && var2 >= 0) {
  769.          this.method_4();
  770.          return this.field_2.engineDoFinal((byte[])null, 0, 0, var1, var2);
  771.       } else {
  772.          throw new IllegalArgumentException("Bad arguments");
  773.       }
  774.    }
  775.  
  776.    public final byte[] doFinal(byte[] var1) throws IllegalBlockSizeException, BadPaddingException {
  777.       this.method_12();
  778.       if (var1 == null) {
  779.          throw new IllegalArgumentException("Null input buffer");
  780.       } else {
  781.          this.method_4();
  782.          return this.field_2.engineDoFinal(var1, 0, var1.length);
  783.       }
  784.    }
  785.  
  786.    public final byte[] doFinal(byte[] var1, int var2, int var3) throws IllegalBlockSizeException, BadPaddingException {
  787.       this.method_12();
  788.       if (var1 != null && var2 >= 0 && var3 <= var1.length - var2 && var3 >= 0) {
  789.          this.method_4();
  790.          return this.field_2.engineDoFinal(var1, var2, var3);
  791.       } else {
  792.          throw new IllegalArgumentException("Bad arguments");
  793.       }
  794.    }
  795.  
  796.    public final int doFinal(byte[] var1, int var2, int var3, byte[] var4) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
  797.       this.method_12();
  798.       if (var1 != null && var2 >= 0 && var3 <= var1.length - var2 && var3 >= 0) {
  799.          this.method_4();
  800.          return this.field_2.engineDoFinal(var1, var2, var3, var4, 0);
  801.       } else {
  802.          throw new IllegalArgumentException("Bad arguments");
  803.       }
  804.    }
  805.  
  806.    public final int doFinal(byte[] var1, int var2, int var3, byte[] var4, int var5) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
  807.       this.method_12();
  808.       if (var1 != null && var2 >= 0 && var3 <= var1.length - var2 && var3 >= 0 && var5 >= 0) {
  809.          this.method_4();
  810.          return this.field_2.engineDoFinal(var1, var2, var3, var4, var5);
  811.       } else {
  812.          throw new IllegalArgumentException("Bad arguments");
  813.       }
  814.    }
  815.  
  816.    public final int doFinal(ByteBuffer var1, ByteBuffer var2) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
  817.       this.method_12();
  818.       if (var1 != null && var2 != null) {
  819.          if (var1 == var2) {
  820.             throw new IllegalArgumentException("Input and output buffers must not be the same object, consider using buffer.duplicate()");
  821.          } else if (var2.isReadOnly()) {
  822.             throw new ReadOnlyBufferException();
  823.          } else {
  824.             this.method_4();
  825.             return this.field_2.engineDoFinal(var1, var2);
  826.          }
  827.       } else {
  828.          throw new IllegalArgumentException("Buffers must not be null");
  829.       }
  830.    }
  831.  
  832.    public final byte[] wrap(Key var1) throws IllegalBlockSizeException, InvalidKeyException {
  833.       if (!(this instanceof NullCipher)) {
  834.          if (!this.field_6) {
  835.             throw new IllegalStateException("Cipher not initialized");
  836.          }
  837.  
  838.          if (this.field_7 != 3) {
  839.             throw new IllegalStateException("Cipher not initialized for wrapping keys");
  840.          }
  841.       }
  842.  
  843.       this.method_4();
  844.       return this.field_2.engineWrap(var1);
  845.    }
  846.  
  847.    public final Key unwrap(byte[] var1, String var2, int var3) throws InvalidKeyException, NoSuchAlgorithmException {
  848.       if (!(this instanceof NullCipher)) {
  849.          if (!this.field_6) {
  850.             throw new IllegalStateException("Cipher not initialized");
  851.          }
  852.  
  853.          if (this.field_7 != 4) {
  854.             throw new IllegalStateException("Cipher not initialized for unwrapping keys");
  855.          }
  856.       }
  857.  
  858.       if (var3 != 3 && var3 != 2 && var3 != 1) {
  859.          throw new InvalidParameterException("Invalid key type");
  860.       } else {
  861.          this.method_4();
  862.          return this.field_2.engineUnwrap(var1, var2, var3);
  863.       }
  864.    }
  865.  
  866.    // $FF: renamed from: a (java.security.AlgorithmParameters) java.security.spec.AlgorithmParameterSpec
  867.    private AlgorithmParameterSpec method_13(AlgorithmParameters var1) throws InvalidParameterSpecException {
  868.       if (var1 == null) {
  869.          return null;
  870.       } else {
  871.          String var2 = var1.getAlgorithm().toUpperCase(Locale.ENGLISH);
  872.          if (var2.equalsIgnoreCase("RC2")) {
  873.             return var1.getParameterSpec(RC2ParameterSpec.class);
  874.          } else if (var2.equalsIgnoreCase("RC5")) {
  875.             return var1.getParameterSpec(RC5ParameterSpec.class);
  876.          } else if (var2.startsWith("PBE")) {
  877.             return var1.getParameterSpec(PBEParameterSpec.class);
  878.          } else {
  879.             return var2.startsWith("DES") ? var1.getParameterSpec(IvParameterSpec.class) : null;
  880.          }
  881.       }
  882.    }
  883.  
  884.    // $FF: renamed from: c (java.lang.String) javax.crypto.SunJCE_f
  885.    private static SunJCE_f method_14(String var0) throws NullPointerException, NoSuchAlgorithmException {
  886.       if (var0 == null) {
  887.          throw new NullPointerException();
  888.       } else {
  889.          String[] var1 = method_0(var0);
  890.          return SunJCE_h.f.a(var1[0]);
  891.       }
  892.    }
  893.  
  894.    public static final int getMaxAllowedKeyLength(String var0) throws NoSuchAlgorithmException {
  895.       SunJCE_f var1 = method_14(var0);
  896.       return var1.c();
  897.    }
  898.  
  899.    public static final AlgorithmParameterSpec getMaxAllowedParameterSpec(String var0) throws NoSuchAlgorithmException {
  900.       SunJCE_f var1 = method_14(var0);
  901.       return var1.e();
  902.    }
  903. }
  904.